Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 2 - Shape Objects / Shape Objects Reference
Application-Defined Spool Function /


MySpoolProc

The QuickDraw GX functions GXFlattenShape and GXUnflattenShape require the calling application to supply a pointer to a function that, respectively, saves flattened data or supplies data to be flattened. The flattening/unflattening spool function has the following interface:

long MySpoolProc(gxSpoolCommand command, 
                  struct gxSpoolBlock *block);
command
A selector with which QuickDraw GX specifies the operation the spool function is to perform.
block
A pointer to the spool block used for the current flattening or unflattening operation.
function result
Zero if the unflattening or flattening operation can continue; nonzero if QuickDraw GX must abort the operation.
DESCRIPTION
The purpose of the flattening/unflattening spool function is to move flattened data into or out of memory as instructed by QuickDraw GX. You place a pointer to the spool function in the appropriate field of the spool block structure that you allocate before calling GXFlattenShape or GXUnflattenShape.

Your spool function should respond to the command parameter and perform the appropriate operation. Constants for the recognized spool commands are defined in the gxSpoolCommands enumeration:
ConstantValueExplanation
gxOpenReadSpool1The spool function is to open the flattened file
for reading into the buffer used by GXUnflattenShape.
gxOpenWriteSpool2The spool function is to open a file for receiving
data from the buffer used by GXFlattenShape.
gxReadSpool3The spool function is to read the data into the
buffer for use by GXUnflattenShape.
gxWriteSpool4The spool function is to write the data placed into the buffer by GXFlattenShape to the file.
gxCloseSpool6The spool function is to close the file.

Your spool function's function result is a status indicator to QuickDraw GX. If the operation must be aborted (for example, if a file error occurs), return a nonzero value as the function result. Otherwise, return 0 and the flattening or unflattening operation can continue.

For simple flattening and unflattening, your spool function need only read and write the amounts of data specified by QuickDraw GX. However, you can also write a spool function that actually parses the data stream during flattening and unflattening; see Listing 2-5 on page 2-41 for an example.

SPECIAL CONSIDERATIONS
During a flattening or unflattening procedure, a memory error can cause a restart of the function, which might not necessarily reset the stream back to its original position. Therefore, your open, read, and write routines must always be sure to set the stream to the correct position in the buffer each time.

SEE ALSO
The spool block structure is described on page 2-49.

The GXFlattenShape function is described on page 2-88. The GXUnflattenShape function is described on page 2-90.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996